#include<stdio.h>
#include<stdlib.h>
#include <cmath> 
int arrayinput(double m[], int n)
	{
		int i;
		printf ("Input array:\n");
		for(i=0; i<n;i++)
			{
				if(scanf("%lf", &m[i])!=1)
					{
						return i;
					}
			}
	}
double min(double m[], int n)
	{
		double min, max;
		int i;
		for(i=0; i<n;i++)
			{
		if(i==0)
			{
				min=m[0];
			}
			if(m[i]<min) min=m[i];
			}
		return min;
	}
double max(double m[], int n)
	{
		double min, max;
		int i;
		for(i=0; i<n;i++)
			{
		if(i==0)
			{
				max=m[0];
			}
			if(m[i]>max) max=m[i];
			}
		return max;
	}
double median(double m[], int n)
	{
		int check, u, i;
		double k;
		for(u=0;u<n;u++)
		{
			for(i=0;i<n-i;i++)
				{
					if(m[i]>m[i+1])
						{
							k=m[i];
							m[i]=m[i+1];
							m[i+1]=k;
						}
				}
		}
	check = n%2;
	if(check==0)
		{
			return (m[n/2]+m[(n/2)-1])/2;	
		}
	else
		{
			return m[n/2];
		}
	}
double arithmeticmean(double m[], int n)
	{
		int i;
		double s=0;
		for(i=0; i<n; i++)
			{
				s=s+m[i];
			}
		return s/n;
	}
double stddev(double m[], int n)
	{
		double ms=0;
		int i;
		for(i=0; i<n; i++)
			{
				ms=ms+((1.0/n)*(m[i]-arithmeticmean(m,n))*(m[i]-arithmeticmean(m,n)));
			}
		return sqrt(ms);
	}
int mnocie(double m[], int n)
	{
		int i, cc=0, v=1;
		for(i=1; i<n; i++)
			{
				if(m[i-1]==m[i])
					{
						v++;
						if((i==n-1)||(m[i]!=m[i+1]))
							{
								if(cc<v) cc=v;
								v=1;
							}

					}
			}
		return cc;
	}
int mlomsoce(double m[], int n)
	{
		int i, mc=0, mv=0, j=1, k=1;
		for(i=1; i<n; i++)
			{
				if(m[i-1]<=m[i])
					{
						j++;
						if((i==n-1)||(m[i]>m[i+1]))
							{
								if(mc<j) mc=j;
								j=1;
							}

					}
				if(m[i-1]>=m[i])
					{
						k++;
						if((i==n-1)||(m[i]<m[i+1]))
							{
								if(mv<k) mv=k;
								k=1;
							}

					}
			}
		if(mc>mv)
			{
				return mc;
			}
		else
			{
				return mv;
			}
	}
									



void main()
{
	int w, i;
	double m[1000];
	w=arrayinput(m, 1000);
	printf("MIN = %lf; MAX = %lf; Arithmetic mean = %lf;\n Standard deviation = %fl;\n he maximum number of consecutive identical elements = %d;\n", min(m, w), max(m, w), arithmeticmean(m, w), stddev(m, w), mnocie(m,w));
	printf("The maximum length of a monotone section of consecutive elements = %d;\nMedian = %lf.\n", mlomsoce(m,w), median(m,w));
	system("PAUSE");
}

